package com.spoplar.topics;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;


public class JMSConsumer3 {
	public static final String USERNAME =ActiveMQConnection.DEFAULT_USER ;  //用户名
	public static final String PASSWORD =ActiveMQConnection.DEFAULT_PASSWORD ; //密码
	public static final String BROKER_URL =ActiveMQConnection.DEFAULT_BROKER_URL ; //消息总线

	public static final int SENDNUMS = 10;
	public static void main(String[] args) throws JMSException {
		
		ConnectionFactory connectionFactory;
		Connection connection;
		Session session;
		Destination destination;
		MessageConsumer messageConsumer;
		
		connectionFactory = new ActiveMQConnectionFactory(
				JMSConsumer3.USERNAME, 
				JMSConsumer3.PASSWORD, 
				JMSConsumer3.BROKER_URL);
		connection = connectionFactory.createConnection();
		connection.start();
		session = connection.createSession(Boolean.FALSE, Session.AUTO_ACKNOWLEDGE);
		destination=session.createTopic("topic 1");
		messageConsumer=session.createConsumer(destination);
		messageConsumer.setMessageListener(new Listener1());
	}
	
}
